package cn.edu.nuc.android.oweibo.activities;

import cn.edu.nuc.android.oweibo.R;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class LogoActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//取消标题
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		//取消状态栏
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.logo);
		
//		dataHelper = DataBaseContext.getInstance(getApplicationContext());
//		userList = dataHelper.GetUserList(false);
		//得到默认用户
//		SharedPreferences preferences = getSharedPreferences("default_user",Activity.MODE_PRIVATE);
//		final String nick = preferences.getString("user_default_nick", "");
		//得到布局文件里的ImageView控件
		ImageView imageView=(ImageView)this.findViewById(R.id.logo);
//		//得到首页图片
//		imageView.setImageResource(R.drawable.login_first);
		AlphaAnimation aa=new AlphaAnimation(0.1f,1.0f);
		aa.setDuration(3000);
		imageView.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener(){
			@Override
			public void onAnimationEnd(Animation arg0){
//				if(userList.size()<1||userList==null){//如果数据库没有存在一个用户的话那么跳往授权界面，添加用户
//					Intent it=new Intent(LogoActivity.this,AccountActivity.class);
//					startActivity(it);
//					finish();
//				}else if("".equals(nick)){//如果数据库存在用户但是没有选择默认登录的用户的话，跳往选择默认登录用户界面
//					Intent it=new Intent(LogoActivity.this,AccountActivity.class);
//					startActivity(it);
//					finish();
//				}else{//如果数据库存在用户并且保存了默认的用户的话,那么跳往次微博用户的默认主界面
//					Intent it=new Intent(LogoActivity.this,MainActivity.class);
//					startActivity(it);
//					finish();
//				}
				Intent intent = new Intent(LogoActivity.this, StatusListActivity.class);
				startActivity(intent);
				finish();
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
				
			}
			@Override
			public void onAnimationStart(Animation animation) {
				
			}
		}
		);
	}
}
